<?php
class session{
	protected $namespace;
	public function __construct($namespace=''){
		@session_start();
		if($namespace){
			$this->namespace =$namespace;
		}else{
			$this->namespace = $_SERVER['HTTP_HOST'];
		}
		if(!isset($_SESSION[$this->namespace])){
			$_SESSION[$this->namespace]=array();
		}
	}
	public function setSession($name,$value){
		$_SESSION[$this->namespace][$name]=$value;
	}
	public function getSession($name=''){
		if($name&&isset($_SESSION[$this->namespace][$name])){
			return $_SESSION[$this->namespace][$name];
		}else if(!$name&&isset($_SESSION[$this->namespace])){
			return $_SESSION[$this->namespace];
		}
	}
	public function getAllSession(){
		return $_SESSION;
	}
	public function destroySession($name=''){
		if($name&&isset($_SESSION[$this->namespace][$name])){
			unset($_SESSION[$this->namespace][$name]);
		}else if(!$name&&isset($_SESSION[$this->namespace])){
			unset($_SESSION[$this->namespace]);
		}
	}
	
}
?>